//
//  FirstViewController.m
//  视图控制器的生命周期
//
//  Created by 伍银荣 on 2021/6/23.
//  Copyright © 2021 com.example. All rights reserved.
//

#import "FirstViewController.h"
#import "SecondViewController.h"

@interface FirstViewController ()

@end

@implementation FirstViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"FirstVC";
    
   // self.navigationItem.titleView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil];
    self.view.backgroundColor = [UIColor redColor];
    
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(100, 200, 200, 40)];
    [btn setTitle:@"跳转到SecVC" forState:UIControlStateNormal];
    [self.view addSubview:btn];
    [btn addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(itemClicked)];
    self.navigationItem.rightBarButtonItem = item;
}

- (void)btnClicked {
    NSLog(@"跳转到SecVC");
    [self.navigationController pushViewController:[SecondViewController new] animated:YES];
}

- (void)itemClicked {
    NSLog(@"---itemClicked---");
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
